package com.guapi.service.impl;

import com.guapi.entity.User;
import com.guapi.repository.UserRepository;
import com.guapi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl extends CacheServiceImpl<User> implements UserService {

    @Autowired
    private MongoTemplate mongoTemplate;
    @Autowired
    private UserRepository userRepository;


    @Override
    public List<User> getAllUsers() {
        return userRepository.findAll();
    }

    @Override
    public void insert(User user) {
        mongoTemplate.save(user);
    }

    @Override
    public void delById(String id) {
        userRepository.deleteById(id);
    }


    @Override
    public User getUserByUsername(String username) {
        return userRepository.findUserByUsername(username);
    }
}
